package com.wutong.eams.service;

import com.wutong.eams.mapper.BaseMapper;
import com.wutong.eams.other.ConditionBuilder;
import com.wutong.eams.other.Page;

import java.util.List;

public interface IService<M extends BaseMapper<E>, E> {
    M getMapper();

    default int insert(E entity) {
        return getMapper().insert(entity);
    }

    default int update(E entity, ConditionBuilder conditionBuilder) {
        return getMapper().update(entity, conditionBuilder);
    }

    default int delete(ConditionBuilder conditionBuilder) {
        return getMapper().delete(conditionBuilder);
    }

    default int count(ConditionBuilder conditionBuilder) {
        return getMapper().count(conditionBuilder);
    }

    default List<E> select(ConditionBuilder conditionBuilder) {
        return getMapper().select(conditionBuilder);
    }

    default E selectOne(ConditionBuilder conditionBuilder) {
        return getMapper().selectOne(conditionBuilder);
    }

    default Page<E> selectPage(ConditionBuilder conditionBuilder, int pageNum, int pageSize) {
        return getMapper().selectPage(conditionBuilder, pageNum, pageSize);
    }
}